function h=histall(data, bin, dmax, dmin)
d = data(:);
if nargin < 3
    dmax = max(d);
end
if nargin < 4
    dmin = min(d);
end
if (dmax - dmin < eps)
    error('All values are the same.');
end
% normalize
d = (d - dmin) * (bin - 1) / (dmax - dmin);
h = hist(d, 0:bin-1);
h = h / sum(h);
if nargout < 1
    bar(0:bin-1, h);
    axis([-1, bin, 0, max(h)]);
end
end
